<template>
	<s-page custom-class="Popup-Page">
		<view>
			<view class="MyInfo">
				<view class="userPicImg">
					<!-- <image :src="imgurl" mode="scaleToFill"></image> -->
					<image src="/static/image/juxing.png" mode="scaleToFill"></image>
				</view>
				<view class="name">
					<text>{{hname}}</text>
				</view>
			</view>
			<form class="loginForm" @submit="testLogin">
				<view class="uni-form-item uni-column" style="width: 690rpx;" v-show="false">
					<uni-easyinput class="my_input" id="my_input" name="input" v-model="username" placeholder="请输入账户名"
						:styles="styles" trim="all" disabled="" :clearable="true">
					</uni-easyinput>
					<!-- <text v-model="username"></text> -->
				</view>
				<view class="uni-form-item uni-column" style="margin-bottom: 70px; width: 690rpx;">
					<uni-easyinput class="my_input" id="my_input" type="password" name="input" v-model="password"
						placeholder="请输入密码" :styles="styles" trim="all">
					</uni-easyinput>
				</view>
				<view class="uni-btn-v">
					<button form-type="submit" type="primary">下一步</button>
				</view>
				<s-popup v-model="autoCloseVisible" animate="zoom-in" position="center" background="#fff" width="400"
					:duration="2000" radius="20">
					<view class="s-popup-view">
						<text class="s-popup-title">{{s_title}}</text>
						<text class="s-popup-main">{{s_errorMsg}}</text>
					</view>
				</s-popup>
			</form>
		</view>
		<s-popup v-model="autoCloseVisible" animate="zoom-in" position="center" background="#fff" width="400"
			:duration="2000" radius="20">
			<view class="s-popup-view">
				<text class="s-popup-title">{{s_title}}</text>
				<text class="s-popup-main">{{s_errorMsg}}</text>
			</view>
		</s-popup>
	</s-page>
</template>

<script>
	import Dialog from '@/uni_modules/s-ui/utils/dialog'; //弹出框引入
	export default {
		data() {
			return {
				imgurl: '11',
				username: 'kk',
				password: '',
				hname:'',
				styles: {
					borderColor: '#EBEFF6'
				},
				autoCloseVisible: false, //弹出框
				s_errorMsg: '', //报错提示
				s_title: '', //报错标题
			}
		},
		onLoad(option) {
			// console.log(option)
			this.username = option.loginname
			this.imgurl = option.imgurl
			this.hname=option.username
		},
		methods: {
			async testLogin() {
				const res = await this
					.$myRequest({ //await 关键字 只能放在 async 函数内部， await关键字的作用 就是获取 Promise中返回的内容， 获取的是Promise函数中resolve或者reject的值
						url: '/api-portal/login',
						method: "post",
						data: {
							userName: this.username,
							password: this.password,
							moduleName: "workerApp"
						},
					})
				// let errorMsg = res.msg
				if (res.success == true) { //如果登录成功
					this.s_title = "验证通过"
					this.s_errorMsg = "正在前往资料编辑页"
					this.autoCloseVisible = true;
					console.log(res)
					console.log(res.body.currentUser.id)
					setTimeout(function() {
						uni.navigateTo({
							url: '/pages/user/ModifyData/ModifyData?department=' + JSON.stringify(res
									.body.currentUser
									.department) + '&ideee=' + res.body.currentUser.id + '&loginName=' +
								res.body.currentUser.loginName + '&roleId=' + JSON.stringify(res.body
									.currentUser.systemRole) + '&description=' + res.body.currentUser
								.description + '&id=' + res.body.currentUser.id + '&name=' + res
								.body.currentUser.name + '&mobile=' + res.body.currentUser.mobile+'&phone='+res.body.currentUser.phone+'&orderNumber='+res.body.currentUser.orderNumber
						})
					}, 1000)
				} else {
					this.s_title = "验证不通过"
					this.s_errorMsg = res.msg
					this.autoCloseVisible = true;
				}
			}
		}
	}
</script>

<style lang="less">
	.logo-box {
		width: 100%;
		height: 328rpx;
		display: flex;
		align-items: center;
		justify-content: center;
	}

	.login-logo {
		// width: 200rpx;
		height: 200rpx;
		// background-color: #109EF8;
		// border-radius: 50%;
	}

	/* @import url("/static/style/test.css"); */
	.run {
		width: 750rpx; //750rpx,350rpx
	}


	form.loginForm>view {

		// margin: 50rpx;
	}

	.my_input {

		height: 76rpx;
		margin: 20rpx 10rpx;
		// margin: 0 36rpx 10rpx 36rpx;
		line-height: 76rpx;
		position: relative;
	}

	#my_input::after {

		content: "";
		width: 100%;
		height: 2px;
		background: #DBDBDB;
		position: absolute;
		bottom: 0;
		left: -20rpx;
		right: 0;
		margin: 0 auto;
	}

	.forget-register {
		color: #B0B0B0;
		margin: 62rpx 0 84rpx 0;
		padding: 0 36rpx 0 0;
		display: flex;
		justify-content: flex-end;
	}

	.forget-register text:nth-child(2) {
		margin: 0 20rpx 0 20rpx;
	}

	.uni-btn-v {
		margin: 0 auto;
		width: 700rpx;
	}

	.uni-form-item {
		// border: 1px solid #FF8095;
		margin: 0 auto;
	}

	.s-popup-view {
		// background-color: #0062CC;
		width: 100%;
		height: 100%;
		display: flex;
		flex-direction: column;
		justify-content: center;
		align-items: center;

		.s-popup-title {
			// display: block;
			// position: absolute;
			// top: 30rpx;
			font-size: 38rpx;
			height: 76rpx;
			line-height: 76rpx;
		}

		.s-popup-main {
			font-size: 34rpx;
			margin: 30rpx 30rpx;
			// position: absolute;
			// bottom: 0;
		}

	}

	.userPicImg {
		border-radius: 6px;
		width: 202rpx;
		height: 202rpx;
		margin: 0 26rpx 0 36rpx;
		background-repeat: no-repeat;
		background-size: 100%;
		// .userPic('userPicImg')

		image {
			border-radius: 100%;
			width: 202rpx;
			height: 202rpx;
		}
	}
	.MyInfo{
		width: 100%;
		height: 330rpx;
		// border:#2979FF solid 1px;
		display: flex;
		align-items: center;
		
		text{
			font-size: 36rpx;
		}
		
	}
</style>
